/**
 * This controller manages the User details view which are added as tabs (so multiple
 * instances are created). Each instance of the view creates an instance of this class to
 * control its behavior.
 */
Ext.define('DCApp.view.img.DetailController', {
    extend: 'DCApp.controller.DetailController',
    alias: 'controller.imgdetail',

    requires: [
        'Ext.window.Toast'
    ],
    onSaveClick: function() {
        var form = this.lookupReference('form'),
            rec;
        
        if (form.isValid()) {
            rec = this.getViewModel().get('theObj');
            Ext.Msg.wait('保存', '保存影像中...');
            rec.save({
                scope: this,
                callback: this.onComplete
            });
        }
    },
    onComplete: function() {
    	var vw = this.getView();
    	var title = vw.title;
        Ext.Msg.hide();
        Ext.toast({
            title: '保存',
            html: title+'保存完成',
            align: 't',
            bodyPadding: 10
        });
        //判断,有返回按钮才返回
        var btn_return = vw.down('button[text=返回]');
        if(!btn_return.isHidden())
        	this.onBackClick();
        else{
        	vw.up('window').close();
        }
    }
    
});
